package com.rd.student.dashuju.zhengchengxiang.July13th.Test;

import java.util.*;

public class ManagementSystem {
    public static void main(String[] args) {
        LinkedList list = new LinkedList();
        Student s1 = new Student("郑成祥", "数据", 1, 80, "有责任心", 1500);
        Student s2 = new Student("王博", "数据", 3, 40, "学习好", 1100);
        Student s3 = new Student("孙文卓", "数据", 1, 18, "有毅力", 1200);
        Student s4 = new Student("郑睿娴", "数据", 1, 18, "有恒心", 1300);
        Student s5 = new Student("王高博", "物联网", 3, 21, "学习认真", 1100);
        list.add(s1);
        list.add(s2);
        list.add(s3);
        list.add(s4);
        list.add(s5);
        // 查看所有小组成员
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }

        Scanner sc = new Scanner(System.in);
        i:
        while (true) {
            System.out.println("----------------ManagementSystem----------------");
            System.out.println("1、新增小组成员");
            System.out.println("2、移除小组成员");
            System.out.println("3、根据班级查询成员列表");
            System.out.println("4、根据专业查询成员列表");
            System.out.println("5、根据年龄查询成员列表");
            System.out.println("6、返回所有成员");
            System.out.println("7、小组平均年龄");
            System.out.println("8、根据年龄范围返回成员列表");
            System.out.println("9、查看列表");
            System.out.println("10、退出");
            System.out.println("请输入你要选择的功能：");
            int i1 = sc.nextInt();
            switch (i1) {
                case 1:
                    // 1、新增小组成员          郑成祥
                    Student.add(list);
                    break;
                case 2:
                    // 2、移除小组成员          王博
                    RemoveUtils.remove(list);
                    break;
                case 3:
                    // 3、根据班级查询成员列表   王高博
                    GetListUtils.getClassInfo(list);
                    break;
                case 4:
                    // 4、根据专业查询成员列表    郑成祥
                    Major.major(list);
                    break;
                case 5:
                    // 5、根据年龄查询成员列表   郑睿娴
                    Age.age(list);
                    break;
                case 6:
                    // 6、返回所有成员          孙文卓
                    NameUtils.nameUtils(list);
                    break;
                case 7:
                    // 7、小组平均年龄          郑成祥
                    int avg = Avg.avg(list);
                    System.out.println("平均年龄：" + avg);
                    Collections.sort(list, new Comparator<Object>() {
                        @Override
                        public int compare(Object o1, Object o2) {
                            Student student1 = (Student) o1;
                            Student student2 = (Student) o2;
                            if (student1.getAge() < student2.getAge()) {
                                return 1;
                            } else if (student1.getAge() > student2.getAge()) {
                                return -1;
                            }
                            return 0;
                        }
                    });
                    System.out.println("---------降序---------");
                    for (int i = 0; i < list.size(); i++) {
                        Student student = (Student) list.get(i);
                        System.out.println(student.getName() + ":" + student.getAge());
                    }
                    Collections.reverse(list);
                    System.out.println("---------升序---------");
                    for (int i = 0; i < list.size(); i++) {
                        Student student = (Student) list.get(i);
                        System.out.println(student.getName() + ":" + student.getAge());
                    }
                    break;
                case 8:
                    // 8、根据年龄范围返回成员列表    孙文卓
                    AgeRange.ageRange(list);
                    break;
                case 9:
                    // 9、查看列表
                    for (int i = 0; i < list.size(); i++) {
                        System.out.println(list.get(i));
                    }
                    break;
                case 10:
                    // 10、退出
                    break i;
                default:
                    System.out.println("您输入有误！");
                    break;
            }
        }
    }
}
